/*
DataBlock.h
*/

#ifndef DataBlock_h
#define DataBlock_h

#include <list>
#include "Settings.h"

using namespace std;

class FileSystem;

class DataBlock{
    friend class Cache; //allows the cache to update this block's iterator for the lru list 
    friend class FileSystem; //so FileSystem can read/write the data to/from the actual fs_file
    friend class File;

    public:
        DataBlock(unsigned int id_loc,FileSystem * fs_loc);
        ~DataBlock();
        unsigned int Read(unsigned int offset, unsigned int size, char * buf);
        unsigned int Write(unsigned int offset, unsigned int size, char * buf);
        char * Data;
    private:
        FileSystem * fs;
        unsigned int id; 
        list < DataBlock *>::iterator lru_it; //when we access this block with Cache::GetDataBlock, we use this iterator to move this DataBlock to the end of the LRU list
};

#endif
